<?php 
error_reporting(E_ALL|E_STRICT);
set_include_path('../include');
require_once('Zend/Loader.php');
Zend_Loader::registerAutoload();
 
$config = new Zend_Config_Ini('../settings.ini','development');
Zend_Registry::set('config', $config);
 
date_default_timezone_set($config->utility->timezone);

$logger = new Zend_Log(new Zend_Log_Writer_Stream($config->logging->file));
Zend_Registry::set('logger', $logger);
 
$params = array('host' => $config->database->hostname,
                 'username' => $config->database->username,
                 'password' => $config->database->password,
                 'dbname'   => $config->database->database);
 
$db = Zend_Db::factory($config->database->type, $params);
Zend_Registry::set('db', $db);
 
$auth = Zend_Auth::getInstance();
$auth->setStorage(new Zend_Auth_Storage_Session());
$controller = Zend_Controller_Front::getInstance();
$controller->setControllerDirectory($config->paths->base.
         '/include/Controllers');
$controller->throwExceptions(true);
$controller->registerPlugin(new CustomControllerAclManager($auth));
 
$view = new Zend_Controller_Action_Helper_ViewRenderer();
$view->setView(new Templater());
$view->setViewSuffix('tpl');
Zend_Controller_Action_HelperBroker::addHelper($view);
 
$route = new Zend_Controller_Router_Route('space/:username/:action/*',
                                           array('controller' => 'space',
                                                 'action' => 'index'));
$controller->getRouter()->addRoute('space', $route);
 
$route = new Zend_Controller_Router_Route('space/:username/article/:url/*',
                                           array('controller' => 'space',
                                                 'action' => 'article'));
$controller->getRouter()->addRoute('article', $route);
 
$route = new Zend_Controller_Router_Route('space/:username/circle/:url/*',
                                           array('controller' => 'space',
                                                 'action' => 'circle'));
$controller->getRouter()->addRoute('circle', $route);
 
$route = new Zend_Controller_Router_Route('space/:username/album/:url/*',
                                           array('controller' => 'space',
                                                 'action' => 'album'));
$controller->getRouter()->addRoute('album', $route);
 
$route = new Zend_Controller_Router_Route('space/:username/message/:url/*',
                                           array('controller' => 'space',
                                                 'action' => 'message'));
$controller->getRouter()->addRoute('message', $route);
 
$route = new Zend_Controller_Router_Route('space/:username/friend/:url/*',
                                           array('controller' => 'space',
                                                 'action' => 'friend'));
$controller->getRouter()->addRoute('friend', $route);
 
$route = new Zend_Controller_Router_Route('space/:username/attach/:url/*',
                                           array('controller' => 'space',
                                                 'action' => 'attach'));
$controller->getRouter()->addRoute('attach', $route);
 
$route = new Zend_Controller_Router_Route('space/:username/guestbook/:url/*',
                                           array('controller' => 'space',
                                                 'action' => 'guestbook'));
$controller->getRouter()->addRoute('guestbook', $route);
 
$route = new Zend_Controller_Router_Route('space/:username/application/:url/*',
                                           array('controller' => 'space',
                                                 'action' => 'application'));
$controller->getRouter()->addRoute('application', $route);
$controller->dispatch();
?>